package com.framework.loippi.controller.api;

import com.framework.loippi.api.utils.ApiUtils;
import com.framework.loippi.entity.Doctor;
import com.framework.loippi.service.DoctorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName DoctorController
 * @Description TODO
 * @Author fsociety
 * @Date 5/12/2019 下午5:12
 * @Version 1.0
 */
@Controller("apiDoctorController")
@RequestMapping("/api/doctor")
@Api(tags = {"医生相关信息"})
public class DoctorController extends ApiBaseController {

    @Resource
    DoctorService doctorService;

    @RequestMapping(value = "/findAllByDeId.json", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "根据科室id获取所有医生")
    public @ResponseBody
    String findListByDeId(@Param(value="departmentId") Integer departmentId) {
        List<Doctor> list = doctorService.findListByDeId(departmentId);

        return ApiUtils.success(list);
    }

    @RequestMapping(value = "/findById.json", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "根据id查询医生信息")
    public @ResponseBody
    String findListById(@Param(value="doctorId") Long doctorId) {
        Doctor doctor = doctorService.find(doctorId);

        return ApiUtils.success(doctor);
    }

    @RequestMapping(value = "/findAll.json", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "查询所有医生")
    public @ResponseBody
    String findAll() {
        List<Doctor> doctors = doctorService.findAll();

        return ApiUtils.success(doctors);
    }
}
